home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / TBUTIL2.LZH / DECBIN.INC < prev    next >
Text File  |  1984-07-13  |  653b  |  23 lines

  1. PROCEDURE DecBin(VAR DecInt:INTEGER;VAR Bin:Btype);
  2. { This procedure converts an integer (DecInt) into a binary number
  3. { that is stored in a character array (Bin) which is 17 characters long.
  4. { The bits are stored with the LSB in Bin[17].
  5. { Danny Cavasos        June 1984 }
  6. CONST
  7.   Divisor : INTEGER = 2;
  8. VAR
  9.   Result,Remainder,i : INTEGER;
  10.   Temp                      : STRING[1];
  11. BEGIN
  12.   FOR i:=1 TO 17 DO Bin[i]:=' ';
  13.   i:=18;
  14.   REPEAT
  15.     Result := DecInt DIV Divisor;
  16.     Remainder := DecInt MOD Divisor;
  17.     i:=i-1;
  18.     STR(Remainder:1,Temp);
  19.     Bin[i]:=Temp;
  20.     DecInt:=Result;
  21.   UNTIL (Result=0) AND (Remainder=0);
  22. END;
  23.